<?php if (!$this->isSuccess):?>

<style type="text/css">
<!--
#add_question_form div.form-label
{
  float: none;
  text-align: left;
  margin: 0px;
  padding: 0px 0px 5px 0px;
}
html[dir="rtl"] #add_question_form div.form-label
{
  text-align: right;
}
#add_question_form div.form-element
{
  float: none;
}
.answer_correct{
	height: 25px;
}
.answer_correct input{
	margin-top: 2px;
}
-->
</style>
<script type="text/javascript">
var index_answer_next = 1;
function cleartext(field){
	if(field.defaultValue == field.value) 
		field.value = '';
	else if(field.value == '')		
		field.value=field.defaultValue;	
};

function addAnswerMore(){
	
//	$more_label = new Element('div',{
//		'class' : 'more_label',
//		'id' : 'more_label',
//		}).inject($('answer_more-wrapper'),'before');	
			
//	$label = new Element('label',{ 
//		'text' : 'Answer',
//        'class' : 'Answer',
//		}).inject($more_label);
		
	$answer = new Element('input',{ 
        'class' : 'answer',
        type : 'text', 
        name: 'answer[]',  
        value : '<?php echo $this->translate('Add answer...');?>',
        defaultvalue: '<?php echo $this->translate('Add answer...');?>',
        onfocus: 'cleartext(this)',
        onblur: 'cleartext(this)'        
		}).inject($('answer-element').getElements('input').getLast(),'after');
	
	return $answer;
};
function addIsCorrectMore(){
	$div = new Element('div', {
		'class' : 'answer_correct'
	}).inject($('correct-element').getElements('.answer_correct').getLast(),'after');
	$correct = new Element('input',{
		 'class' : 'answer_correct',
		 type : 'checkbox',		
		 name : 'answer_correct_' + index_answer_next
		}).inject($div);
}
window.addEvent('domready', function(){
	
	$('answer_more').addEvents({
		'click': function(e){
			cleartext(this);
			e.stop();
			$answer_last_value =  $('answer-element').getElements('input').getLast().get('value');
			if($answer_last_value != '<?php echo $this->translate('Add answer...');?>' && $answer_last_value != ''){
				$answer = addAnswerMore();
				$correct = addIsCorrectMore();
				$answer.getParent().getChildren('input').getLast().focus();
				index_answer_next++;	
			}
		}									
	});

	$$('.answer').addEvents({
		'focus': function(){
			cleartext(this);
			},			
		'blur': function(){
			cleartext(this);
		}									
		});		
});	
</script>
<form id="<?php echo $this->form->getAttrib('id');?>" name="<?php echo $this->form->getAttrib('name');?>" enctype="multipart/form-data" action="<?php echo $this->escape($this->form->getAction()) ?>" method="<?php echo $this->escape($this->form->getMethod()) ?>" class="global_form">
    <div>
        <div>
            <h3>
                <?php echo $this->translate($this->form->getTitle()) ?>
            </h3>
            <p class="form-description"><?php echo $this->translate($this->form->getDescription()) ?></p>
            <div class="form-elements">
            	<?php echo $this->form->category;?>
            	<?php echo $this->form->content; ?>
            	<?php //echo $this->form->answer; ?>
            	<div class="form-wrapper" id="answer-wrapper">
            	  <div class="answer_left" style="width: 225px;float: left;">
            		<div class="form-label" id="answer-label">
            			<label class="optional" ><?php echo $this->translate('Answer')?></label>
            		</div>
					<div class="form-element" id="answer-element">
						<input type="text" class="answer" defaultvalue="<?php echo $this->translate('Add answer...')?>" value="<?php echo $this->translate('Add answer...')?>" name="answer[]">
					</div>
				  </div>
				  <div class="answer_correct" style="float: left;">
				  	<div class="form-label">
            			<label class="optional" ><?php echo $this->translate('Is Correct')?></label>
            		</div>
					<div class="form-element" id="correct-element">
						<div class="answer_correct">					
						 <input type="checkbox" name="answer_correct_0">
						</div>
					</div>
				  </div>
				</div>
						           	
            	
            	<div class="form-wrapper" >
            		<div class="form-label" ></div>
					<div class="form-element" >
						<a style="cursor: pointer" class="buttonlink icon_more_answer" id="answer_more"><?php echo $this->translate('Add More')?></a>
					</div>
				</div>
				
				<?php echo $this->form->buttons; ?>
			</div>
            <br>
            <br>
            <br>
		</div>
	</div>
</form>

<?php else:?>
<script type="text/javascript">
    //load ajax : addressedit
    parent.loadQuestions('<?php echo $this->exam->getIdentity() ?>');
    setTimeout(function()
    {
        parent.Smoothbox.close();
    }, 2000);
</script>
<div class="global_form_popup_message" style="padding: 5px;">
        <?php echo $this->translate('This question was created.'); ?>
</div>
<?php endif;?>